Re: [GENERAL] Sufficient Primary Key?

Поиск
Список
Период
Сортировка
От lynch@lscorp.com (Richard Lynch)
Тема Re: [GENERAL] Sufficient Primary Key?
Дата
Msg-id v02140b1ab1de4337210b@[207.152.64.133]
обсуждение исходный текст
Список pgsql-general
At 11:06 AM 7/24/98, Dan Delaney wrote:
>Hello all.
>   I'm working on a library catalog and trying to decide what to use
>for the primary key for the authors. Do you think that the first
>three letters of first and last name with the birth year would be
>sufficient (e.g., Alan Watts would be ALAWAT1915). So, essentially,
>do you think there there would ever be two authors with the same
>first and last name AND the same birth year? I really don't want to
>inject the middle name into there because I can't find the middle
>name (or even middle initial) of most authors!

My personal preference is *always* for an integer primary key, which has no
contextual meaningful connection whatsoever with the actual data.

In this particular instance, since you clearly are unsure that you can ever
guarantee uniqueness, there shouldn't even be a question about it:  Use an
auto-incrementing integer.

create sequence authorId;

create table authors(
  Id int4 unique not null default nextval('authorId'),
  .
  .
  .
);

--
--
-- "TANSTAAFL" Rich lynch@lscorp.com



В списке pgsql-general по дате отправления:

Предыдущее
От: Matt McClure
Дата:
Сообщение: Re: [GENERAL] Nested tables
Следующее
От: lynch@lscorp.com (Richard Lynch)
Дата:
Сообщение: Re: [GENERAL] Re: [HACKERS] [Fwd: SGVLLUG Oracle and Informix on Linux]